package com.hc.service;

import com.hc.jian.JianMapper;
import com.hc.nong.NongMapper;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @Autowired
    private JianMapper jianMapper;

    @Autowired
    private NongMapper nongMapper;


    @GlobalTransactional
    public void transfer(int fromId, int toId, double monoey) {
        nongMapper.reduceMoney(fromId, monoey);
        int i = 10 / 0;
        jianMapper.increaseMoney(toId, monoey);
    }

}
